<?php
function convertDatePicker($datepicker, $format)
{
       $datepicker = str_replace(array('\'', '/', '.', ',', ' '), '-', $datepicker);
   	   $datepickerparts = explode('-', $datepicker);

	   $month = $datepickerparts[0];
	   $day   = $datepickerparts[1];
	   $year  = $datepickerparts[2];

	   if (strlen($day) < 2)
	   {
		  $day = '0'.$day;
	   }

	   
	   switch ($format)
	   {
	   case "DDMMYYYY" :
		  return ($day.'-'.$month.'-'.$year);
		  break;

	   case "MMDDYYYY" :
		  return ($month.'-'.$day.'-'.$year);
		  break;

	   case "YYYYMMDD" :
		  return ($year.'-'.$month.'-'.$day);
		  break;
	  
	   default :
		  return ($errmsg);
	   }
   
   
}
?>
